using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace UTLBASEFORM
{
    public partial class MyControl : UserControl
    {
        public MyControl()
        {
            InitializeComponent();
            txtLuong.GotFocus += new EventHandler(txtLuong_GotFocus);
            txtLuong.LostFocus += new EventHandler(txtLuong_LostFocus);
        }

        void txtLuong_LostFocus(object sender, EventArgs e)
        {
            if(txtLuong.Tag.Equals(txtLuong.Text.Trim()))
            {

                return;
            }
            txtLuong.Tag = txtLuong.Text;
        }

        void txtLuong_GotFocus(object sender, EventArgs e)
        {
            txtLuong.Tag = txtLuong.Text;
        }
        public string Luong
        {
            get {
                string strLuong = "0";
                strLuong=txtLuong.Text.Trim();
                if (strLuong == "")
                {
                    strLuong = "0";
                }
                return strLuong;
            }
            set { txtLuong.Text = value; }
        }
        public int ILuong
        {
            get
            {
                string strLuong = "0";
                strLuong = txtLuong.Text.Trim();
                if (strLuong == "")
                {
                    return 0;
                }
                return int.Parse(strLuong);
            }            
        }
        public string Chi
        {
            get {
                string strChi = "0";
                strChi= txtChi.Text.Trim();
                if (strChi == "")
                {
                    strChi = "0";
                }
                return strChi;
            }
            set { txtChi.Text = value; }
        }
        public int IChi
        {
            get
            {
                string strChi = "0";
                strChi = txtChi.Text.Trim();
                if (strChi == "")
                {
                    return  0;
                }
                return int.Parse( strChi);
            }            
        }
        public string Phan
        {
            get { 
                string strPhan = "0";
                strPhan=txtPhan.Text.Trim();
                if (strPhan == "")
                {
                    strPhan = "0";
                }
                return strPhan;
            }
            set { txtPhan.Text = value; }
        }
        public int IPhan
        {
            get
            {
                string strPhan = "0";
                strPhan = txtPhan.Text.Trim();
                if (strPhan == "")
                {
                    return 0;
                }
                return int.Parse( strPhan);
            }            
        }
        public string Li
        {
            get {
                string strLi = "0";
                strLi=txtLi.Text.Trim();
                if (strLi == "")
                {
                    strLi = "0";
                }
                return strLi;
            }
            set { txtLi.Text = value; }
        }
        public int ILi
        {
            get
            {
                string strLi = "0";
                strLi = txtLi.Text.Trim();
                if (strLi == "")
                {
                    return 0;
                }
                return int.Parse( strLi);
            }            
        }
        public string PhanLe
        {
            get {
                string strPhanLe = "0";
                strPhanLe=txtPhanLe.Text;
                if (strPhanLe == "")
                {
                    strPhanLe = "0";
                }
                return strPhanLe;
            }
            set { txtPhanLe.Text = value; }
        }
        public int IPhanLe
        {
            get
            {
                string strPhanLe = "0";
                strPhanLe = txtPhanLe.Text;
                if (strPhanLe == "")
                {
                    return 0;
                }
                return int.Parse( strPhanLe);
            }            
        }

        public string getValue
        {
            get
            {
                string strResult = "";
                string _luong = "0";
                string _chi = "0";
                string _phan = "0";
                string _li = "0";
                string _phanle = "0";
                if (!txtLuong.Text.Trim().Equals(""))
                {
                    _luong = lblLuong.Text;
                }
                if (!txtChi.Text.Trim().Equals(""))
                {
                    _chi = lblChi.Text;
                }
                if (!txtPhan.Text.Trim().Equals(""))
                {
                    _phan = lblPhan.Text;
                }
                if (!txtLi.Text.Trim().Equals(""))
                {
                    _li = lblLi.Text;
                }
                if (!txtPhanLe.Text.Trim().Equals(""))
                {
                    _phanle = txtPhanLe.Text;
                }
                strResult = _luong + ";" + _chi + ";" + _phan + ";" + _li;
                return strResult;
            }



        }

        private void ControlShow_Load(object sender, EventArgs e)
        {
            
        }

        private void txtLuong_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void txtPhanLe_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void txtChi_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void txtLi_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void txtPhan_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;
        }

        private void txtLuong_TextChanged(object sender, EventArgs e)
        {

        }

        
    }
}
